package com.example.simpletask

import android.graphics.Color

/**
 *  存储每个步骤的颜色的单例，并提供方法获得该步骤数下该进度对应的颜色
 */
object BgColor {
    private val colorArray = intArrayOf(
        Color.parseColor("#5ca7c2"),
        Color.parseColor("#20d2fa"),
        Color.parseColor("#9820fa"),
        Color.parseColor("#c7a4c4"),
        Color.parseColor("#fcbcb3"),
        Color.parseColor("#fbe46f"),
        Color.parseColor("#30e873"),
        Color.parseColor("#c1c1c1"),
    )

    public fun get(steps: Int, stage: Int): Int {
        var color: Int = colorArray[7]
        if (steps > 0) {
            when (steps) {
                1 -> when (stage) {
                    0 -> color = colorArray[0]
                    1 -> color = colorArray[6]
                }
                2 -> when (stage) {
                    0 -> color = colorArray[0]
                    1 -> color = colorArray[1]
                    2 -> color = colorArray[6]
                }
                3 -> when (stage) {
                    0 -> color = colorArray[0]
                    1 -> color = colorArray[1]
                    2 -> color = colorArray[5]
                    3 -> color = colorArray[6]
                }
                4 -> when (stage) {
                    0 -> color = colorArray[0]
                    1 -> color = colorArray[1]
                    2 -> color = colorArray[3]
                    3 -> color = colorArray[5]
                    4 -> color = colorArray[6]
                }
                5 -> when (stage) {
                    0 -> color = colorArray[0]
                    1 -> color = colorArray[1]
                    2 -> color = colorArray[3]
                    3 -> color = colorArray[4]
                    4 -> color = colorArray[5]
                    5 -> color = colorArray[6]
                }
                6 -> when (stage) {
                    0 -> color = colorArray[0]
                    1 -> color = colorArray[1]
                    2 -> color = colorArray[2]
                    3 -> color = colorArray[3]
                    4 -> color = colorArray[4]
                    5 -> color = colorArray[5]
                    6 -> color = colorArray[6]
                }
            }
        }
        return color
    }
}